package com.china.zhuoyue.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Window
import com.china.zhuoyue.ui.R
import com.china.zhuoyue.ui.utils.SafeDialogHandle

class LoadingDialog(context: Context) : Dialog(context, R.style.loadingdialog) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        setContentView(R.layout.dialog_loading)
    }

    override fun show() {
        if (!isShowing) {
            try {
                super.show()
//                if (tvProgress != null) tvProgress.text = ""
            } catch (e: Exception) {
            }
        }
    }

//    fun setProgress(progress: Int) {
//        tvProgress.text = progress.toString()
//    }
//
//    fun setText(text: String?) {
//        if (tvText != null) {
//            tvText.text = text
//            tvText.visibility = View.VISIBLE
//        }
//    }
}

fun LoadingDialog.safeShowDialog() {
    SafeDialogHandle.safeShowDialog(this)
}

fun LoadingDialog.safeDismissDialog() {
    SafeDialogHandle.safeDismissDialog(this)
}